import {RouterMount,createRouter} from 'uni-simple-router';

const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,  
	routerErrorEach:({type,msg})=>{
		console.log({type,msg})
		// #ifdef APP-PLUS
			if(type===3){
				router.$lockStatus=false;
				uni.showModal({
					title: '提示',
					content: '您确定要退出应用吗？',
					success: function (res) {
						if (res.confirm) {
							plus.runtime.quit();
						} 
					}
				});
			}
		// #endif
	},
	routes: [...ROUTES]
});

router.beforeEach((to, from, next) => {
	console.log('前守卫者')
	console.log('---------从哪来--------')
	console.log(from)
	console.log('--------从哪来结束--------')
	console.log('---------去哪里-----------')
	console.log(to)
	console.log('--------去哪里结束--------')
	next();
});
// 全局路由后置守卫
router.afterEach((to, from) => {
	console.log('后守卫者')
})

export {
	router,
	RouterMount
}